package com.tongji.seller.view
{
	import com.tongji.seller.events.ChangePropertyEvent;
	import com.tongji.seller.events.GetStoreSceneDetailEvent;
	import com.tongji.seller.events.HideFurnitureEvent;
	import com.tongji.seller.model.FurnitureModel;
	import com.tongji.seller.model.GetSystemSceneModel;
	import com.tongji.seller.model.StoreSceneModel;
	import com.tongji.seller.utils.PopUpAdmin;
	import com.tongji.seller.utils.Showroom;
	
	import flash.events.MouseEvent;
	
	import mx.binding.utils.BindingUtils;
	import mx.controls.Alert;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 *
	 * @author caddy
	 * @date 2011-12-21
	 */
	public class WorkMediatore extends Mediator
	{
		[Inject]
		public var view:Work;
		
		[Inject]
		public var storeSceneModel:StoreSceneModel;
		
		[Inject]
		public var furnitureModel:FurnitureModel;
		[Inject]
		public var getSystemSceneModel:GetSystemSceneModel;
		private var wholeScene:Object = new Object(); //整个场景，Object类型，包含三个defaultScene
		public var selectedScene:Object = new Object(); //某个场景，Object类型，45度或者90度或者135度
		override public function onRegister():void
		{
			eventMap.mapListener(view.shadowBtn, MouseEvent.CLICK, setShadowHandler, MouseEvent);
			eventMap.mapListener(view.deleteBtn, MouseEvent.CLICK, deleteFurHandler, MouseEvent);
			eventMap.mapListener(view.changeBtn, MouseEvent.CLICK, changeFurHandler, MouseEvent);
			eventMap.mapListener(view.brightBtn, MouseEvent.CLICK, setBrightHandler, MouseEvent);
		}
		
		/**
		 * 对选中的宝贝进行亮度设置 
		 * @param event
		 * 
		 */
		private function setBrightHandler(event:MouseEvent):void
		{
			if (furnitureModel.selectedFur != null)
				PopUpAdmin.popupCenterWindow(PopUpAdmin.BRIGHT_TITLE_WIN, view, mediatorMap, false);
			else
				Alert.show("请选择要设置的宝贝");			
		}
		
		/**
		 * 对选中的宝贝进行阴影设置 
		 * @param event
		 * 
		 */		
		private function setShadowHandler(event:MouseEvent):void
		{
			if (furnitureModel.selectedFur != null)
				PopUpAdmin.popupCenterWindow(PopUpAdmin.FILTER_TITLE_WIN, view, mediatorMap, false);
			else
				Alert.show("请选择要设置的宝贝");
		}
		
		/**
		 * 删除选中的宝贝 
		 * @param event
		 * 
		 */		
		private function deleteFurHandler(event:MouseEvent):void
		{
			if (furnitureModel.selectedFur != null)
				furnitureModel.deleteSelectedObj();
			else
				Alert.show("请选择要删除的宝贝");
		}
		
		/**
		 * 切换宝贝 
		 * @param event
		 * 
		 */		
		private function changeFurHandler(event:MouseEvent):void
		{
			if (furnitureModel.selectedFur != null)
				PopUpAdmin.popupCenterWindow(PopUpAdmin.CHANGE_PRODUCT_TITLE_WIN, view, mediatorMap);
			else
				Alert.show("请选择要设置的宝贝");
		}
	}
}